package chat.fragments;

import android.app.DialogFragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;

import com.whu.zj.R;

/**
 * Created by Administrator on 2016/1/15.
 */
public class ReleaseFromJoinGroupFragment extends DialogFragment {

    String groupId;

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    View v_releaseGroup;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        View rootView = inflater.inflate(R.layout.fragment_releasefromjoingroup,null);
        initview(rootView);
        return rootView;
    }

    // 初始化view
    private void initview(View rootView) {
        v_releaseGroup = rootView.findViewById(R.id.id_v_releaseGroup);
        v_releaseGroup.setOnClickListener(itemclick);
    }

    View.OnClickListener itemclick = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (v == v_releaseGroup)
            {
//                DeleteUserFromGroup.Upload upload = new DeleteUserFromGroup.Upload();
//                upload.setGroupID(groupId);
//                upload.setUserID(UserInfo.getUserID());
//                new DeleteUserFromGroup(new DeleteUserFromGroup.Delegate() {
//                    @Override
//                    public void onResponse(String response, DeleteUserFromGroup deleteFromGroup) {
//                        if (deleteFromGroup.getDownload().getStatus() == DeleteUserFromGroup.Download.SUCCESS)
//                        {
//                            LoginModel.deleteGroupByID(groupId);
//                            Intent intent = new Intent(ReleaseFromJoinGroupFragment.this.getActivity(),IMMessageReceiver.class);
//                            intent.setAction(IMMessageReceiver.NOTIFYGROUPCHANGED);
//                            ReleaseFromJoinGroupFragment.this.getActivity().sendBroadcast(intent);
//                            ReleaseFromJoinGroupFragment.this.dismiss();
//                        }
//                    }
//
//                    @Override
//                    public void onErrorResponse(VolleyError error, DeleteUserFromGroup deleteFromGroup) {
//
//                    }
//                }, upload).delete();
            }
        }
    };
}
